package ltg.ibutton.core.wrappers;

import java.util.ArrayList;

public abstract class Wrapper {
	
	//public static Wrapper getInstance() { return null; }
	public abstract ArrayList<String> getAll();
	public abstract ArrayList<String> getButtons();
	public abstract ArrayList<String> getReaders();
	public abstract ArrayList<String> getButtonsFromPort(String portName);
	
	public ArrayList<String> getButtonsFromReader(String readerid) {
		ArrayList<String> readersList = this.getReaders();
		return getButtonsFromPort("USB" + (readersList.indexOf(readerid) + 1));
		/*assuming ports are scanned in increasing id order*/
	}
	
	public String toString() {
		ArrayList<String> readersList = this.getReaders();
		String out = "";
		int i = 0;
		while(i < readersList.size()) {
			out += readersList.get(i);
			ArrayList<String> buttonsList = this.getButtonsFromReader(readersList.get(i));
			int j = 0;
			while(j < buttonsList.size())
				out += "\n\t|-------- " + buttonsList.get(j++);
			i++;
			out += "\n";
		}
		return out;
	}

}
